/**
 * Created by Administrator on 2017/3/18 0018.
 */
import React from "react";
import {Checkbox} from 'antd';
import {Switch} from 'antd';
import {hashHistory} from 'react-router';
import Util from "../../util/Util";
/*导出组件*/
export default class SuggestItem extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            ischeckde: false,
            isswitch: this.props.ele.status,
            ele: this.props.ele,
            int: 1,
            status: 1
        }
        this.int = 1
        this.uid = this.props.ele.uid
    }

    componentWillMount() {
        this.setState({
            ele: this.props.ele
        });
    }

    reply() {
        this.props.replyInfo(this.state.ele.sid);
    }

    replyDetail() {
            hashHistory.push("/ReplyDetail/" + this.state.ele.sid);
    }

    checkisunchose() {
        this.setState({
            ischeckde: false
        });
        this.int = 1
    }

    switchcontrol(is) {
        this.setState({
            isswitch: is
        });
    }


    render() {

        return (
            <tr style={{height: "40px"}}>
                {/*<th style={{border: "1px solid #ccc"}}><Checkbox*/}
                    {/*style={{display: "block", float: "left", marginLeft: "12px"}}*/}
                    {/*onClick={this.checkboxchose.bind(this)} checked={this.state.ischeckde} ref={'checkbox'}/></th>*/}
                {/*<th style={{border: "1px solid #ccc" ,display:"none"}}>{this.state.ele.sid}</th>*/}
                <th style={{border: "1px solid #e7e7e7",padding:"3px 10px"}}><a href="javascript:;" onClick={this.replyDetail.bind(this)}>{this.state.ele.detail}</a></th>
                <th style={{border: "1px solid #e7e7e7" ,color:"#ff3300"}}>{this.judge(this.state.ele.ifReply)}</th>
                <th style={{border: "1px solid #e7e7e7"}}>{this.dateFormat(this.state.ele.updateDate)}</th>
                <th style={!Util.authorityCheck("ticking") ? {display: 'none',border: "1px solid #e7e7e7"} :{border: "1px solid #e7e7e7"}}>
                    <a className=".limit_duty_edit_i" href="javascript:;" onClick={this.reply.bind(this)}>回复</a>
                </th>
                {/*<th style={{border: "1px solid #ccc"}}>{this.state.ele.phone}</th>*/}
                {/*<th style={{border: "1px solid #ccc"}}>{this.state.ele.status == 0 ? "禁用" : "启用"}</th>*/}
                {/*<th style={{border: "1px solid #ccc"}}><Switch checked={this.state.isswitch}*/}
                                                               {/*onChange={this.switchchose.bind(this)}/></th>*/}
            </tr>
        )
    }

    /*日期格式化*/
    dateFormat(time) {
        let zero = (n) => {
            return n = n > 0 && n < 10 ? "0" + n : n;
        };
        let y = new Date(time).getFullYear();
        let m = new Date(time).getMonth()+1;
        let d = new Date(time).getDate();
        // let h = new Date(time).getHours();
        // let ms = new Date(time).getMinutes();

        // return zero(y)+"-"+zero(m)+"-"+zero(d)+" "+zero(h)+":"+zero(ms);
        return zero(y) + "-" + zero(m) + "-" + zero(d)
    }

    judge(ifReply){
        if(ifReply=="0"){
            return "未回复"
        }else{
            return "已回复"
        }
    }

}